package cn.befory.controller;

import cn.befory.pojo.Perm;
import cn.befory.service.PermService;
import cn.befory.tools.ResponseContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author befory
 * @since 2010-10-14
 * @version 1.0
 */
@RestController
@RequestMapping("/perm")
public class PermController {
    @Autowired
    private PermService permService;
    @GetMapping("/menus/{uid}")
    public ResponseEntity getMenu(@PathVariable Long uid) throws Exception {
        return ResponseEntity.ok(ResponseContent.success(permService.getMenus(uid)));
    }

    @GetMapping("/menus/{uid}/{param}")
    public ResponseEntity getMenu(@PathVariable Long uid,@PathVariable String param) throws Exception {
        return ResponseEntity.ok(ResponseContent.success(permService.getMenus(uid,param)));
    }

    @PostMapping("/add/{uid}")
    public ResponseEntity addPerm(@RequestBody Perm perm,@PathVariable String uid) throws Exception{
        return ResponseEntity.ok(ResponseContent.success(permService.addPerm(perm)));
    }
}
